<?php
/**
* @package YARBB
* @copyright Авторские права (C) 2009 www.yar-it.com. Все права защищены.
* @license Лицензия http://www.gnu.org/licenses/gpl-2.0.htm GNU/GPL, или help/license.php
* YARBB! - свободное программное обеспечение распространяемое по условиям лицензии GNU/GPL
* Для получения информации о используемых расширениях и замечаний об авторском праве, смотрите файл copyright.php.
*/

	defined( '_JEXEC' ) or die( 'Restricted Access' );
	global $ybbConfig;
	$dispclr = $this->theme;
	$userArray = array();
?>

<div class="ybbmaindiv">
  <table class="ybbnormaltable" cellpadding="0" cellspacing="0" >
    <tr>
      <td class="ybbtopleft"></td>
      <td class="ybbtopmiddle"><?php echo $ybbConfig->boardname;?> </td>
      <td class="ybbtopright"></td>
    </tr>
    <tr>
      <td class="ybbleftbody"></td>
      <td class="ybbheaderrow"><table class="ybbnormaltable" cellpadding="5" cellspacing="5">
          <tr>
            <td><div id="yarbb_menu">
                <ul id="ybbmenu">
                  <?php echo $this->userprofile['home']; ?>
                  <li class="node"><a>Инструменты</a>
                    <ul>
                      <?php echo $this->userprofile['latest']; ?> 
					  <?php echo $this->userprofile['link']; ?> 
					  <?php echo $this->userprofile['mylist']; ?> 
					  <?php echo $this->userprofile['approval']; ?>
                    </ul>
                  </li>
                </ul>
              </div></td>
            <td class="ybbheaderusername"><?php echo JText::_('WELCOME') . ' ' . $this->userprofile['boardusername']; ?></td>
            <td class="ybbheaderavatar"><?php echo $this->userprofile['thumb']; ?></td>
          </tr>
        </table></td>
      <td class="ybbrightbody"></td>
    </tr>
    <?php foreach($this->sticky as $rec) { ?>
    <tr>
      <td class="ybbleftbody"></td>
      <td class="ybbheaderrow"><table class="ybbnormaltable" cellpadding="0" cellspacing="0">
          <tr class="ybbfrmrow_sticky">
            <td class="ybbtopicicon"><img src="<?php echo YARBB_ASSETS_URL_THEME.'/'.$dispclr; ?>/img/sticky<?php echo $rec->topic_type; ?>.gif" class="ybbiconimg" /></td>
            <td class="ybblinetop"><a href="<?php echo JRoute::_($this->posturl .'&forum=' . (int)$rec->forum_id . '&topic=' . (int)$rec->id . '&Itemid=' . $ybbConfig->itemid) ; ?>"> <b><?php echo $this->escape($rec->post_subject); ?></b> </a>&nbsp; </td>
            <td class="ybbfrmlast"><?php
								if( $rec->post_time != 0 ) {
									if( $rec->post_user > 0 ) {
										if( isset( $userArray[$rec->post_user])) {
											$uname = $userArray[$rec->post_user];
										} else {
											$uname = yarbbHelperConfig::getUserName( $rec->post_user );
											$userArray[$rec->post_user] = $uname;
										}
                                        $uname = '<a href="'. JRoute::_('index.php?option=com_yarbb&view=myprofile&cid=' . $rec->post_user . '&Itemid=' . $ybbConfig->itemid ) . '">' . $uname . '</a>';
									} else {
										$uname = $rec->post_username;
									}
									echo JText::_('POST_LIST_BY') . '&nbsp;<b>'. $uname . '</b>&nbsp;' . JText::_('POST_LIST_ON') . '&nbsp;' .
									JHTML::_('date', $rec->post_time + $ybbConfig->timeoffset, $ybbConfig->dateformat);
								}
							?>
            </td>
          </tr>
        </table></td>
      <td class="ybbrightbody"></td>
    </tr>
    <?php } ?>
    <tr class="ybbtablefooter">
      <td class="ybbbotleft"></td>
      <td class="ybbbotmiddle"></td>
      <td class="ybbbotright"></td>
    </tr>
    <tr>
      <td class="ybbcolspacer"></td>
      <td></td>
      <td></td>
    </tr>
    <?php
	    	$cat_id=0;
	    	$i = 0;
	    	$n = count($this->items);
	    	while($i < $n && $n > 0) {
	    		$rec = $this->items[$i];
				$cat_id = $rec->cat_id;
		?>
    <tr>
      <td class="ybbtopleft"></td>
      <td class="ybbtopmiddle">&nbsp; <a href="<?php echo JRoute::_('index.php?option=com_yarbb&view=forumlist&cat='. $cat_id . '&Itemid=' . $ybbConfig->itemid); ?>"> <span class="textwhite"><?php echo $this->escape($rec->cat_name); ?></span> </a> </td>
      <td class="ybbtopright"></td>
    </tr>
    <tr>
      <td class="ybbleftbody"></td>
      <td class="ybbdatacolumn"><table class="ybbnormaltable" cellpadding="0" cellspacing="0">
          <tr class="ybbfrmrowheader">
            <td class="ybbfrmrowcol1" ></td>
            <td class="ybbfrmrowcol2"><?php echo $this->labels['forums'] ?></td>
            <td class="ybbfrmrowcol3"><?php echo $this->labels['topics'] ?></td>
            <td class="ybbfrmrowcol4" ><?php echo $this->labels['posts'] ?></td>
            <td class="ybbfrmrowcol5"><?php echo $this->labels['lastpost'] ?></td>
          </tr>
          <?php
						while($i < $n) {
							$rec = $this->items[$i];
							if( $rec->cat_id != $cat_id) break;
					?>
          <tr class="ybbfrmrowheader">
            <td class="ybbtopicicon"><img src="<?php echo YARBB_ASSETS_URL_THEME.'/'.$dispclr; ?>/img/forum<?php  
			if($rec->locked == 1) { echo '-locked'; } 
			elseif($rec->review == 1) echo '-review'; ?>.png" alt="" /> </td>
            <td class="ybblinetop" align="left"><a href="<?php echo JRoute::_($this->topicurl . '&forum='. (int) $rec->id .'&Itemid=' . $ybbConfig->itemid); ?>" title="<?php echo htmlentities($rec->forum_name, ENT_COMPAT, 'UTF-8'); ?>"> <b><?php echo htmlentities($rec->forum_name, ENT_COMPAT, 'UTF-8'); ?></b> </a><br />
              <?php echo htmlentities($rec->forum_desc, ENT_COMPAT, 'UTF-8'); ?> </td>
            <td class="ybblinetop" align="center"><?php echo number_format((int)$rec->topic_count); ?></td>
            <td class="ybblinetop" align="center"><?php echo number_format((int)$rec->post_count); ?></td>
            <td class="ybblinetop" align="left"><?php
			            				if( $rec->last_post_time != 0 && $rec->topic_count > 0 ) {
                                            //echo '<a href="' . JRoute::_($this->posturl . '&forum='. $rec->id .'&topic='. (int) $rec->topic_id . '&Itemid=' . $ybbConfig->itemid . yarbbHelperConfig::getPageNumber($rec->topic_id, $rec->last_post_id)) . '">'. $this->escape($rec->post_subject) . '</a>&nbsp;';
											$name = $this->escape( $rec->post_subject );
											
											echo '<a href="' . JRoute::_($this->posturl . '&forum='. $rec->id .'&topic='. (int) $rec->topic_id . '&Itemid=' . $ybbConfig->itemid . yarbbHelperConfig::getPageNumber($rec->topic_id, $rec->last_post_id)) .  '" title="'.$name.'">';
											
											if (strlen($name) > '25') {
											
                                            echo JString :: substr($name, 0, '25').'...' .'&nbsp;';
											
											} else {
											echo $name.'&nbsp;';
											}
											echo '<img src="' . YARBB_ASSETS_URL_THEME .'/'. $dispclr. '/img/lastpost.gif" alt="" />';
											echo '</a><br/>';
			            					if( $rec->last_post_user > 0 ) {
												if( isset( $userArray[$rec->last_post_user])) {
													$uname = $userArray[$rec->last_post_user];
												} else {
													$uname = yarbbHelperConfig::getUserName( $rec->last_post_user );
													$userArray[$rec->last_post_user] = $uname;
												}
                                                $uname = '<a href="'. JRoute::_('index.php?option=com_yarbb&view=myprofile&cid=' . $rec->last_post_user . '&Itemid=' . $ybbConfig->itemid ) . '">' . $uname . '</a>';
			            					} else { $uname = $rec->last_post_username; }
											echo JText::_('POST_LIST_BY'). '&nbsp;<b>' . $uname . '</b><br />';
				            				echo JText::_('POST_LIST_ON') . '&nbsp;' . JHTML::_('date', $rec->last_post_time + $ybbConfig->timeoffset , $ybbConfig->dateformat) ;
			            				}
			            			?>
            </td>
          </tr>
          <?php
					    	$i++;
						}
					?>
        </table></td>
      <td class="ybbrightbody"></td>
    </tr>
    <tr class="ybbtablefooter">
      <td class="ybbbotleft"></td>
      <td class="ybbbotmiddle"></td>
      <td class="ybbbotright"></td>
    </tr>
    <tr>
      <td class="ybbcolspacer"></td>
      <td></td>
      <td></td>
    </tr>
    <?php
        }  /* Main Loop */
       if( $ybbConfig->showboardsummary == 1) {
    ?>
    <tr>
      <td class="ybbtopleft"></td>
      <td class="ybbtopmiddle">&nbsp;<b><?php echo JText::_('BOARD_STATISTICS'); ?></b></td>
      <td class="ybbtopright"></td>
    </tr>
    <tr>
      <td class="ybbleftbody"></td>
      <td class="ybbboardsummary"><div class="graphleft"> <img src="<?php echo YARBB_ASSETS_URL_THEME.'/'.$dispclr; ?>/img/graph.png" alt="<?php echo JText::_('BOARD_STATISTICS'); ?>" /> </div>
        <div class="graphright">
          <?php
                        echo JText::_('YBB_TOTAL_CATEGORIES') . ':&nbsp;<b>' . $this->boardsummary->catcount . '</b>&nbsp;';
                        echo JText::_('YBB_TOTAL_FORUMS')  . ':&nbsp;<b>' . $this->boardsummary->forumcount . '</b>&nbsp;';

                        echo JText::_('YBB_TOTAL_THREADS') . ':&nbsp;<b>' . $this->boardsummary->topiccount . '</b>&nbsp;';
                        echo JText::_('YBB_TOTAL_POSTS') . ':&nbsp;<b>' . $this->boardsummary->postcount . '</b><br/>';

                        echo JText::_('YBB_TOTAL_USERS') . ':&nbsp;<b>' . $this->boardsummary->usercount . '</b>&nbsp;';
                        echo JText::_('YBB_LATEST_USERS') . ':&nbsp;';
                        foreach( $this->boardsummary->latestusers as $usr) {
                            echo '<a href="' . JRoute::_('index.php?option=com_yarbb&view=myprofile&cid=' . $usr->id . '&Itemid=' . $ybbConfig->itemid)  .  '">' . $usr->username . '</a>&nbsp;&nbsp;';
                        }
                    ?>
        </div></td>
      <td class="ybbrightbody"></td>
    </tr>
    <tr class="ybbtablefooter">
      <td class="ybbbotleft"></td>
      <td class="ybbbotmiddle"></td>
      <td class="ybbbotright"></td>
    </tr>
    <?php } ?>
  </table>
  <?php
    if (!count($this->items)) {
			echo '<tr><td><p>'. JText::_('FORUMS_NOT_FOUND') .'</p></td></tr>';
	}
 ?>
</div>
<br/>
<?php echo YARBB_COPYRIGHT; ?> <br clear="left" />
